<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="renderer" content="webkit">
	<title>栏目管理</title>
	<link href="css/module.css" rel="stylesheet"/>
	<link href="css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
	<link href="font-awesome/css/font-awesome.css?v=4.3.0" rel="stylesheet">
	<link href="css/animate.css" rel="stylesheet">
	<link href="css/admin-style.css?v=2.2.0" rel="stylesheet">
	<!-- Mainly scripts -->
	<script src="js/jquery-2.1.1.min.js"></script>
	<script src="js/bootstrap.min.js?v=3.4.0"></script>
	<!--Layer-->
	<script src="static/layer/layer.js"></script>
	<script type="text/javascript" src="js/admin.js"></script>
	<script src="js/jquery.metisMenu.js"></script>
</head>
<body>
<div id="wrapper">
	<script>
    $(function(){
        var controller_name = "{:CONTROLLER_NAME}";
        var nav     = $('.nav-second-level a');
        nav.each(function(){
            var url = $(this).attr('href');
            console.log(url);
            if(url.indexOf('/'+controller_name) > 0){
                $(this).parent().addClass('active');
                return false;
            }
        });
    });
</script>

<nav class="navbar-default navbar-static-side" role="navigation">
    <div class="sidebar-collapse">
        <ul class="nav" id="side-menu">
            <li class="nav-header" style="padding: 25px 20px;">
                <div class="dropdown profile-element">
                    <span>
                        <img alt="image" class="img-circle" height="60px" src="images/profile_small.jpg" />
                    </span>
                    <a data-toggle="dropdown" class="dropdown-toggle" href="index.html#">
                            <span class="clear"> </span>
                    </a>
                    <ul class="dropdown-menu animated fadeInRight m-t-xs">
                    </ul>
                </div>
                
            </li>
            <li class="active">
                <a href="#"><i class="fa fa-edit" style="width: 18px"></i> <span class="nav-label">管理</span> <span class="fa arrow"></span></a>
                <ul class="nav nav-second-level">
                    <li><a href="lists1.html">分类模型</a></li>
                    <li><a href="lists2.html">分类栏目</a></li>
                    <li><a href="lists3.html">栏目名称</a></li>
                    <li><a href="lists.html">数据管理</a></li>
                </ul>
            </li>
        </ul>
    </div>
</nav>
<block name="main">
    <div id="page-wrapper" class="gray-bg dashbard-1">
<div class="row border-bottom">
    <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
        <div class="navbar-header">
            <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#">
                <i class="fa fa-bars"></i>
            </a>
        </div>
        <ul class="nav navbar-top-links navbar-right">
            <li>
                <span class="m-r-sm text-muted welcome-message">
                    <a href="{lists.html}" title="返回首页"><i class="fa fa-home"></i>欢迎使用舜网传媒后台</a>
                </span>
            </li>
        </ul>
    </nav>
</div>
<div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加栏目名称</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t " method="post" action="add.html" enctype="multipart/form-data">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">所属分类模型：</label>
                            <div class="col-sm-9">
                                <select id="high_id" name="high_id">
                                    <option value="0">请选择分类模型</option>
                                    <foreach name="high_level" item="vo">
                                        <option value="{$vo.id}" <if condition="($vo.id eq $data['high_id'])">selected</if> >{$vo.high_name}</option>
                                    </foreach>
                                </select>
                                <select id="middle_id" name="middle_id" onchange="get_elementary_info()">
                                    <option value="0">请选择栏目类别</option>
                                    <foreach name="middle_level" item="vo">
                                        <option value="{$vo.id}" <if condition="($vo.id eq $data['middle_id'])">selected</if> >{$vo.middle_name}</option>
                                    </foreach>
                                </select>
                                <select name="elementary_id" id="elementary_id">
                                    <option value="0">请选择栏目名称</option>
                                    <foreach name="elementary_level" item="vo">
                                        <option value="{$vo.id}" <if condition="($vo.id eq $data['elementary_id'])">selected</if> >{$vo.elementary_name}</option>
                                    </foreach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">名称：</label>
                            <div class="col-sm-3">
                                <input  type="text" id="title" class="form-control" name="title" value="{$data.title}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">链接地址：</label>
                            <div class="col-sm-3">
                                <input  type="text" id="href" class="form-control" name="href" value="{$data.href}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否推荐：</label>
                            <div class="col-sm-6">
                                <input type="radio" name="is_recommend" value="0" <if condition="($data.is_recommend neq 1)"> checked </if> > 否
                                <input type="radio" name="is_recommend" value="1" <if condition="($data.is_recommend eq 1)" > checked </if> > 是
                                <span style="color:indianred">（推荐后，会在首页右侧显示）</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">排序：</label>
                            <div class="col-sm-3">
                                <input  type="text" id="sort" class="form-control" name="sort" value="{$data.sort}">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <input type="hidden" name='id' value="{$_GET['id']}">
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
       
    </div>
	<div class="footer">
    <div class="pull-right">
        By<a href="#" target="_blank">舜网传媒</a>
    </div>
    <div>
        <strong>Copyright</strong> 舜网 &copy; 2017
    </div>
</div>
    <script>
        $('#high_id').change(function () {
            var high_id = $('#high_id').val();
            $.ajax({
                type: "POST",
                url: "{:U('get_middle_info')}",
                data: {'high_id': high_id},
                datatype: "text",
                success: function (data) {
                    if (data != '') {
                        $('#middle_id').show();
                        $('#middle_id').empty();
                        $('#middle_id').append(data);
                        get_elementary_info();
                    } else {
                        $('#middle_id').hide();
                        $('#middle_id').empty();
                        $('#elementary_id').hide();
                        $('#elementary_id').empty();

                    }
                }
            });
        });


        function get_elementary_info(){
            var middle_id = $('#middle_id').val();
            $.ajax({
                type:"POST",
                url:"{:U('get_elementary_info')}",
                data:{'middle_id':middle_id},
                datatype:"text",
                success:function(data){
                    if(data != ''){
                        $('#elementary_id').show();
                        $('#elementary_id').empty();
                        $('#elementary_id').append(data);
                    }else{
                        $('#elementary_id').hide();
                        $('#elementary_id').empty();
                    }
                }
            });
        }

        $('form').submit(function(){
            var name = $('#high_name').val();
            var sort = $("#sort").val();
            if(name == ''){
                layer.msg('请填写名称',{time:1000});
                return false;
            }
            if(!sort || isNaN(sort)){
                layer.msg('请填写排序，并且为数字',{time:1000});
                return false;
            }
        });
    </script>
</block>

</div>
</body>
</html>